package com.learning.platform.dto;

import com.learning.platform.enums.ExamType;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Min;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

public class ExamRequest {
    
    @NotNull(message = "课程ID不能为空")
    private Long courseId;
    
    @NotBlank(message = "考试标题不能为空")
    @Size(max = 200, message = "考试标题不能超过200字符")
    private String title;
    
    private String description;
    
    private ExamType examType = ExamType.QUIZ;
    
    @Min(value = 1, message = "考试时长必须大于0分钟")
    private Integer timeLimit;
    
    @DecimalMin(value = "0.0", message = "及格分数不能为负数")
    private BigDecimal passScore = new BigDecimal("60.00");
    
    @Min(value = 1, message = "最大尝试次数必须大于0")
    private Integer maxAttempts = 1;
    
    private LocalDateTime startTime;
    
    private LocalDateTime endTime;
    
    private Boolean showResult = true;
    
    private Boolean showCorrectAnswers = false;
    
    private Boolean shuffleQuestions = false;
    
    private Boolean shuffleOptions = false;
    
    @NotNull(message = "考试题目不能为空")
    @jakarta.validation.Valid
    private List<ExamQuestionRequest> questions;
    
    private BigDecimal totalPoints;
    
    // 内部类：考试题目请求
    public static class ExamQuestionRequest {
        @NotNull(message = "题目ID不能为空")
        private Long questionId;
        
        @NotNull(message = "题目序号不能为空")
        private Integer orderNo;
        
        @DecimalMin(value = "0.1", message = "题目分值必须大于0")
        private BigDecimal points;
        
        // Getters and Setters
        public Long getQuestionId() {
            return questionId;
        }
        
        public void setQuestionId(Long questionId) {
            this.questionId = questionId;
        }
        
        public Integer getOrderNo() {
            return orderNo;
        }
        
        public void setOrderNo(Integer orderNo) {
            this.orderNo = orderNo;
        }
        
        public BigDecimal getPoints() {
            return points;
        }
        
        public void setPoints(BigDecimal points) {
            this.points = points;
        }
    }
    
    // Constructors
    public ExamRequest() {}
    
    // Getters and Setters
    public Long getCourseId() {
        return courseId;
    }
    
    public void setCourseId(Long courseId) {
        this.courseId = courseId;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public ExamType getExamType() {
        return examType;
    }
    
    public void setExamType(ExamType examType) {
        this.examType = examType;
    }
    
    public Integer getTimeLimit() {
        return timeLimit;
    }
    
    public void setTimeLimit(Integer timeLimit) {
        this.timeLimit = timeLimit;
    }
    
    public BigDecimal getPassScore() {
        return passScore;
    }
    
    public void setPassScore(BigDecimal passScore) {
        this.passScore = passScore;
    }
    
    public Integer getMaxAttempts() {
        return maxAttempts;
    }
    
    public void setMaxAttempts(Integer maxAttempts) {
        this.maxAttempts = maxAttempts;
    }
    
    public LocalDateTime getStartTime() {
        return startTime;
    }
    
    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }
    
    public LocalDateTime getEndTime() {
        return endTime;
    }
    
    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }
    
    public Boolean getShowResult() {
        return showResult;
    }
    
    public void setShowResult(Boolean showResult) {
        this.showResult = showResult;
    }
    
    public Boolean getShowCorrectAnswers() {
        return showCorrectAnswers;
    }
    
    public void setShowCorrectAnswers(Boolean showCorrectAnswers) {
        this.showCorrectAnswers = showCorrectAnswers;
    }
    
    public Boolean getShuffleQuestions() {
        return shuffleQuestions;
    }
    
    public void setShuffleQuestions(Boolean shuffleQuestions) {
        this.shuffleQuestions = shuffleQuestions;
    }
    
    public Boolean getShuffleOptions() {
        return shuffleOptions;
    }
    
    public void setShuffleOptions(Boolean shuffleOptions) {
        this.shuffleOptions = shuffleOptions;
    }
    
    public List<ExamQuestionRequest> getQuestions() {
        return questions;
    }
    
    public void setQuestions(List<ExamQuestionRequest> questions) {
        this.questions = questions;
    }
    
    public BigDecimal getTotalPoints() {
        return totalPoints;
    }
    
    public void setTotalPoints(BigDecimal totalPoints) {
        this.totalPoints = totalPoints;
    }
}